using System;
using System.Windows.Forms;
using BizTalk.BuildGenerator.UI.Navigation;

namespace BizTalk.BuildGenerator.UI.UserControls
{
    public partial class UnitTestingControl : UserControl, IWizardControl
    {
        private UnitTesting _UnitTesting = new UnitTesting();

        public UnitTestingControl()
        {
            InitializeComponent();
        }

        private void UnitTestingControl_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                UnitTestingPropertyGrid.SelectedObject = _UnitTesting;
            }
        }

        public void RegisterUnitTesting(UnitTesting unitTests)
        {
            _UnitTesting = unitTests;
        }

        #region IWizardControl Members

        public MoveNextResult MoveNext()
        {
            MoveNextResult result = new MoveNextResult();

            if (_UnitTesting.TestContainers.Count > 0 && string.IsNullOrEmpty(_UnitTesting.TestRunConfigPath))
            {
                result.AddError("Please supply a test run config");
                result.CanMoveNext = false;
            }
            else
                result.CanMoveNext = true;

            return result;
        }

        #endregion
    }
}